]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
gdm/util: Simplify code
authorAlessandro Bono <alessandro.bono369@gmail.com>
Wed, 1 May 2024 18:00:49 +0000 (20:00 +0200)
committerMarge Bot <marge-bot@gnome.org>
Thu, 13 Jun 2024 21:56:36 +0000 (21:56 +0000)
This avoids iterating and checking if a service is foreground
multiple times.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3291>

js/gdm/util.js

index 303be0d62179befd9cd011b64f3aab3f01f24ff9..b5a544c8d6d6aab37083883c421d47a73d0bd3a6 100644 (file)
@@ -892,10 +892,10 @@ export class ShellUserVerifier extends Signals.EventEmitter {
         // If the login failed with the preauthenticated oVirt credentials
         // then discard the credentials and revert to default authentication
         // mechanism.
-        let foregroundService = Object.keys(this._credentialManagers).find(service =>
-            this.serviceIsForeground(service));
-        if (foregroundService) {
-            this._credentialManagers[foregroundService].token = null;
+        const isCredentialManager = !!this._credentialManagers[serviceName];
+        const isForeground = this.serviceIsForeground(serviceName);
+        if (isCredentialManager && isForeground) {
+            this._credentialManagers[serviceName].token = null;
             this._preemptingService = null;
             this._verificationFailed(serviceName, false);
             return;
@@ -909,7 +909,7 @@ export class ShellUserVerifier extends Signals.EventEmitter {
         // if the password service fails, then cancel everything.
         // But if, e.g., fingerprint fails, still give
         // password authentication a chance to succeed
-        if (this.serviceIsForeground(serviceName))
+        if (isForeground)
             this._failCounter++;
 
         this._verificationFailed(serviceName, true);